<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Api\Controller;
use Think\Controller;

/**
 * 前台公共控制器
 * 为防止多分组Controller名称冲突，公共Controller名称统一使用分组名称
 */
class HomeController extends Controller {
    protected function _initialize(){
        /* 读取站点配置 */
        $config = api('Config/lists');
        C($config); //添加配置

        if(!C('WEB_SITE_CLOSE')){
            $this->error('站点已经关闭，请稍后访问~');
        }
    }
    //分享给你
    public function fx()
    {


        if($_POST['id']){
            $arr=array();
            $arr['m_id']=$_POST['id'];
            $arr['time']=date('Y-m-d H:i:s',time());
            M('tfx')->add($arr);

            //得到授权产品
            $shop=M('tshop')->where("start = 1")->order(" id desc")->find();

            //修改状态
            if(M('tmember')->save(array('id'=>$arr['m_id'],'start'=>2,'dqed'=>$shop['id']))){
                exit('ok');
            }

        }
        $id=$_GET['id'];//分享人id
        $this->assign('id',$id);
        $this->assign('ym',$_SERVER['SERVER_NAME']);
        $this->assign('appxz',C('TBD_APPXZ'));
        $this->assign('apptitle',C('WEB_SITE_TITLE'));
        $this->assign('applogo',C('TBD_LOGO'));
        $this->display();
    }

    //微信分享
    public function borrow_fx(){
        //微信分享
        vendor('Wxfx.jssdk');//实例化微信支付
        $jssdk = new \JSSDK("wx9fb7e36e1370a6ca", "5252554d3233e1e51078ed240085ad30");
        $signPackage = $jssdk->GetSignPackage();
        $this->ajaxReturn($signPackage);
    }


    public function fx_tz(){
            $this->display();
     //   header("Location:".C('TBD_APPXZ'));
    }

}
